import time
from xml.etree.ElementPath import xpath_tokenizer

from selenium import webdriver
from selenium.webdriver.common.by import By
# 1.创建浏览器驱动对象
driver=webdriver.Chrome()
# 2.通过get方法获取网页
driver.get("http://localhost:82/")
driver.find_element(By.PARTIAL_LINK_TEXT,"登录").click()
driver.find_element(By.ID,"username").send_keys("13800138006 ")
driver.find_element(By.ID,"password").send_keys("123456")
driver.find_element(By.ID,"verify_code").send_keys("8888")
driver.find_element(By.CLASS_NAME,"J-login-submit").click()
time.sleep(5)
# 4.关闭浏览器对象
driver.quit()


# xpath方法
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
# 1.创建浏览器驱动对象
driver=webdriver.Chrome()
# 2.通过get方法获取网页
driver.get("http://localhost:82/")
# driver.find_element(By.XPATH,"/html/body/div/fieldset/form/div/p/input").send_keys("admin")
driver.find_element(By.XPATH,"/html/body/div/div/div/div/div/a[@class='red']").click()
driver.find_element(By.XPATH,"/html/body/div/div/div/div/form/div/div/input[@id='username' and @class='text_cmu']").send_keys("13800138006 ")
driver.find_element(By.XPATH,"/html/body/div/div/div/div/form/div/div/input[@id='password' and @class='text_cmu']").send_keys("123456")
driver.find_element(By.XPATH,"/html/body/div/div/div/div/form/div/div/input[@id='verify_code' and @class='text_cmu']").send_keys("8888")
driver.find_element(By.XPATH,"/html/body/div/div/div/div/form/div/div/a").click()
time.sleep(5)
# 4.关闭浏览器对象
driver.quit()











































